package org.csu.leiyun.spring.demo.aop.test;

import org.csu.leiyun.spring.demo.aop.persistence.AccountDAO;
import org.csu.leiyun.spring.demo.aop.persistence.AccountDAOimpl;
import org.csu.leiyun.spring.demo.aop.proxy.ProxyDemo;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import javax.annotation.Resource;
import java.lang.reflect.Proxy;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("classpath:applicationContext-aop.xml")
public class Demo {
//    @Resource(name = "demoAfterProxy")
    @Autowired
    private AccountDAO accountDAO;
    @Test
    public void test(){
        accountDAO.find();

//        AccountDAO accountDAO = new AccountDAOimpl();
//        Class class1 = accountDAO.getClass();
////        Object object=Proxy.newProxyInstance(class1.getClassLoader(),class1.getInterfaces(),new ProxyDemo(accountDAO));//object代理accountDAO
////        accountDAO=(AccountDAO)object;
//        accountDAO= (AccountDAO) Proxy.newProxyInstance(class1.getClassLoader(),class1.getInterfaces(),new ProxyDemo(accountDAO));//合并上两步
//        accountDAO.delete();
//        accountDAO.find();


    }
}
